﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Incident_Manager_PUCP
{   
    public partial class frmConsultarCliente : Form
    {
        private GestorCliente gestorcli = GestorCliente.ObtenerInstancia();       

        public frmConsultarCliente()
        {
            InitializeComponent();
        
        
        }
                
        private void btnSalir_Click(object sender, EventArgs e)
        {
            this.Close();

        }

       
        private void button1_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();

            List<Cliente> lista_temp;            
            
            if (textBox2.Text.CompareTo("") != 0)
            {
                lista_temp = gestorcli.BuscarClientes(textBox2.Text);                
            }
            else
            {
                lista_temp = gestorcli.ListaClientes;
            }

            for (int i = 0; i < lista_temp.Count(); i++) {
                int n = dataGridView1.Rows.Add();

                dataGridView1.Rows[n].Cells[0].Value = lista_temp[i].getRUC();
                dataGridView1.Rows[n].Cells[1].Value = lista_temp[i].getRazonSocial();
                dataGridView1.Rows[n].Cells[2].Value = lista_temp[i].getNombreContacto();
                dataGridView1.Rows[n].Cells[3].Value = lista_temp[i].getEmailContacto();
                dataGridView1.Rows[n].Cells[4].Value = lista_temp[i].getDistrito();
                dataGridView1.Rows[n].Cells[5].Value = lista_temp[i].getDireccion();
            }

            dataGridView1.ClearSelection();

        }
    }
}
